﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;

namespace Gundam_2._0_Alpha.src
{
    public class MissionOneLoader:  IAction
    {
        public void DoAction(GameController gc)
        {
            string name = "(Kallen) Gundam Exia",
                   iconLoc = "hotkeys.png";
            Sprite gundamSprite = Sprites.CreateSprite(Resources.LoadBitmap(Resources.PathToResource("CharSprites\\exiaGundam.png")), 5, 96, 320, 240);
                   
            int row = 0, colEnd = 1, count = 7,
                driveOffSetX = 10, driveOffSetY = 60,
                shootOffsetX = gundamSprite.Width /2 - 30 ,
                shootOffsetY = gundamSprite.Height /2 - 40;

            List<DestroyableObject> charList = new List<DestroyableObject>();
            List<Ability> abilitylist = new List<Ability>();
            List<GNParticles> gnDrive = new List<GNParticles>();

            GlobalConst.Utils.ActivateAnimationRow(gundamSprite, row, colEnd, count);

            Player c = new Player(name, gundamSprite,shootOffsetX, shootOffsetY, 200000, new ZakuAI());
            for (int i = 0; i < 1000; i++)
            gnDrive.Add(new GNParticles((int)(gundamSprite.X + gundamSprite.Width / 2) + c.DriveOffSetX(), (int)(gundamSprite.Y + gundamSprite.Height / 2) - driveOffSetY,c));

            c.GnDriveParticles = gnDrive;
            c.MaxPower = 5000;
            c.StateRow = 6;
            c.State = GlobalConst.SpriteState.normalWest;

            AbilitySet tempAbilitySet = new AbilitySet();

            Ability newAbility = new UnTimedAbility(c, KeyCode.vk_RIGHT, "Move Right", 0);
            newAbility.AbilityAction = new Movement(c, false, 1, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 0, Movement.Direction.Right);
            abilitylist.Add(newAbility);

            newAbility = new UnTimedAbility(c, KeyCode.vk_LEFT, "Move Left",  0);
            newAbility.AbilityAction = new Movement(c, false, 2, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 0, Movement.Direction.Left);
            abilitylist.Add(newAbility);

            newAbility = new UnTimedAbility(c, KeyCode.vk_UP, "Move Up",  0);
            newAbility.AbilityAction = new Movement(c, false, GlobalConst.DefaultRow, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 0, Movement.Direction.Up);
            abilitylist.Add(newAbility);

            newAbility = new UnTimedAbility(c, KeyCode.vk_DOWN, "Move Down",  0);
            newAbility.AbilityAction = new Movement(c, false, GlobalConst.DefaultRow, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 0, Movement.Direction.Down);
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_PAGEDOWN, "Unleash Particles",  0);
            newAbility.AbilityAction = new AdjustParticles(c, false, GlobalConst.DefaultRow, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 1, AdjustParticles.Adjust.Add);
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_END, "Surpress Particles",  0);
            newAbility.AbilityAction = new AdjustParticles(c, false, GlobalConst.DefaultRow, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 1, AdjustParticles.Adjust.Subtract);
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_z, "Punch Right",  800);
            newAbility.AbilityAction = new Melee(c, true, 3, 4, GlobalConst.DefaultFPC, 2, 18, false);
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_x, "Punch Left",  800);
            newAbility.AbilityAction = new Melee(c, true, 4, 4, GlobalConst.DefaultFPC, 2, 18, false);
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_c, "Basic Shot",  1000);
            newAbility.AbilityAction = new BasicShot(c, true, 4, 4, GlobalConst.DefaultFPC, 3, 200);
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_t, "TransAm",  40000);
            newAbility.AbilityAction = new TransAm(c, true, 3, 4, GlobalConst.DefaultFPC, 2, "Trans Am", 15000, true, 6, 0.4f, 0.5f, 0.5f);
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_2, "Stasis",  40000);
            newAbility.AbilityAction = new Stasis(c, true, 3, 4, GlobalConst.DefaultFPC, 2, "Stasis", 10000, true, 200);
            newAbility.AbilityAction.Immune = true;
            abilitylist.Add(newAbility);

            foreach (Ability a in abilitylist)
                if (!a.Name.Contains("Move"))
                    a.SetIcon(iconLoc);
/*            newAbility = new Ability(c, KeyCode.vk_a, "Touhou One",  20000);
            newAbility.AbilityAction = new Touhou1(c, true, 4, 4, GlobalConst.DefaultFPC, 4, 100, GlobalConst.ScreenWidth / 2, GlobalConst.ScreenHeight / 2, 15
                , 5000, 10000, false);
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_s, "Touhou Tsu",  60000);
            newAbility.AbilityAction = new Touhou2(c, true, 4, 4, GlobalConst.DefaultFPC, 4, 100, GlobalConst.ScreenWidth / 2, GlobalConst.ScreenHeight / 2, 5
                , true);
            abilitylist.Add(newAbility);

            

            newAbility = new Ability(c, KeyCode.vk_1, "Summon",  1500);
            newAbility.AbilityAction = new Summon(c, true, 3, 4, GlobalConst.DefaultFPC, 3);
            abilitylist.Add(newAbility);


            newAbility = new Ability(c, KeyCode.vk_w, "Void Zone",  100000);
            newAbility.AbilityAction = new VoidZones(c, true, 3, 4, GlobalConst.DefaultFPC, 0, false);
            newAbility.AbilityAction.Immune = true;
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_d, "Gravity",  20000);
            newAbility.AbilityAction = new Gravity(c, true, 3, 4, GlobalConst.DefaultFPC, 0, 300, false, 10000);
            newAbility.AbilityAction.Immune = true;
            abilitylist.Add(newAbility);

            newAbility = new Ability(c, KeyCode.vk_e, "Explode",  20000);
            newAbility.AbilityAction = new Explode(c, true, 3, 4, GlobalConst.DefaultFPC, 0,60000,7000,1000,false);
            newAbility.AbilityAction.Immune = true; 
            abilitylist.Add(newAbility);
            */
            tempAbilitySet.Name = "Test";
            tempAbilitySet.SetOfAbilities = abilitylist;

            c.CurrentSet = tempAbilitySet;
            c.SetofAbiities.Add(c.CurrentSet);

            
            

            charList.Add(c);

           name = "Zaku_01";
           gundamSprite = Sprites.CreateSprite(Resources.LoadBitmap(Resources.PathToResource("CharSprites\\zaku.png")), 5, 1, 320, 240);

           row = 0; colEnd = 1; count = 7;
           driveOffSetX = 10; driveOffSetY = 60;
               shootOffsetX = gundamSprite.Width / 2 - 30;
               shootOffsetY = gundamSprite.Height / 2 - 40;

           abilitylist = new List<Ability>();
           gnDrive = new List<GNParticles>();

           GlobalConst.Utils.ActivateAnimationRow(gundamSprite, row, colEnd, count);

           Character ch = new Character(name, gundamSprite, shootOffsetX, shootOffsetY, 5000, new ZakuAI());
           ch.StateRow = 1;
           ch.State = GlobalConst.SpriteState.normalEast;

           charList.Add(ch);

           name = "Dynames";
           gundamSprite = Sprites.CreateSprite(Resources.LoadBitmap(Resources.PathToResource("CharSprites\\dynames.png")), 5, 100, 320, 240);
           gundamSprite.X = GlobalConst.ScreenWidth/2 - gundamSprite.Width/2;
           gundamSprite.Y = GlobalConst.ScreenHeight/2 - gundamSprite.Height /2;

           row = 0; colEnd = 1; count = 7;
           shootOffsetX = gundamSprite.Width / 2 - 30;
           shootOffsetY = gundamSprite.Height / 2 - 40;

           abilitylist = new List<Ability>();
           tempAbilitySet = new AbilitySet();

           GlobalConst.Utils.ActivateAnimationRow(gundamSprite, row, colEnd, count);

           ch = new Character(name, gundamSprite, shootOffsetX, shootOffsetY, 4000000, new DynamesAI());

           newAbility = new Ability(ch, KeyCode.vk_z, "Slash",  1000);
           newAbility.AbilityAction = new Melee(ch, true, 7, 5, 10, 2, 20, true);
           abilitylist.Add(newAbility);

           newAbility = new UnTimedAbility(ch, KeyCode.vk_RIGHT, "Move Right",  0);
           newAbility.AbilityAction = new Movement(ch, false, 8, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 0, Movement.Direction.Right);
           abilitylist.Add(newAbility);

           newAbility = new UnTimedAbility(ch, KeyCode.vk_LEFT, "Move Left",  0);
           newAbility.AbilityAction = new Movement(ch, false, 9, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 0, Movement.Direction.Left);
           abilitylist.Add(newAbility);

           newAbility = new UnTimedAbility(ch, KeyCode.vk_UP, "Move Up",  0);
           newAbility.AbilityAction = new Movement(ch, false, GlobalConst.DefaultRow, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 0, Movement.Direction.Up);
           abilitylist.Add(newAbility);

           newAbility = new UnTimedAbility(ch, KeyCode.vk_DOWN, "Move Down",  0);
           newAbility.AbilityAction = new Movement(ch, false, GlobalConst.DefaultRow, GlobalConst.DefaultColEnd, GlobalConst.DefaultFPC, 0, Movement.Direction.Down);
           abilitylist.Add(newAbility);

           newAbility = new UnTimedAbility(ch, KeyCode.vk_q, "Balance",  0);
           newAbility.IsActive = true;
           newAbility.AbilityAction = new Balance(ch, true, 3, 4, GlobalConst.DefaultFPC, 0);
           newAbility.AbilityAction.Immune = true;
           abilitylist.Add(newAbility);

           newAbility = new Ability(ch, KeyCode.vk_z, "Shoot",  800);
           newAbility.AbilityAction = new ShootAction(ch, true, 1, 5, 10, 2, 20);
           abilitylist.Add(newAbility);

           tempAbilitySet.SetOfAbilities = abilitylist;
           ch.CurrentSet = tempAbilitySet;
           ch.StateRow = 10;
           ch.State = GlobalConst.SpriteState.normalEast;

           charList.Add(ch);

           Stage newStage = new Stage(true);
            newStage.CharList = charList;
            newStage.StageAction = new List<IAction>();
            newStage.StageAction.Add(new FinishMission(c,"defeat.png"));
            newStage.StageAction.Add(new FinishMission(ch,"victory.png"));
            gc.GameStages.Pop();
            gc.GameStages.Pop();
            Music.Stop();
            gc.GameStages.Push(newStage);            
        }
    }
}
